/*------------------------------------------------------------------------------
 * PROJ : PrototypeWithSpring
 * NAME : sculove.spring.framework.handler.CommonHandlerInterceptor.java
 *        
 * Copyright 2009 sculove All rights reserved
 *------------------------------------------------------------------------------
*/
package sculove.spring.framework.handler;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import sculove.spring.zzz.login.service.LoginService;

/**
 * <pre>
 * sculove.spring.framework.handler.CommonHandlerInterceptor.java
 * TODO
 * 
 * </pre>
 * @date : 2009. 10. 17. 오후 11:52:36
 * @version :
 * @author : sculove
 * @deprecated
 */
public class CommonHandlerInterceptor extends HandlerInterceptorAdapter {
	private final Log logger = LogFactory.getLog(this.getClass());
	@Resource(name="zzz.loginService")
	private LoginService loginService = null;

	public LoginService getLoginService() {
		return loginService;
	}
	

	public void setLoginService(LoginService loginService) {
		this.loginService = loginService;
	}

	@Override 
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
//		if("ajax".equals(request.getHeader("DataHeader-Type"))) {	// AJAX는 조회용으로만 사용 (예외일 경우, 관리)
//			if (logger.isDebugEnabled()) logger.debug("★★★ Reqeust Ajax in PreHandler ★★★");
//		} else {
//			if (logger.isDebugEnabled()) logger.debug("★★★ Reqeust JSP in PreHandler ★★★");
//			
//			/*
//			 * check Request-Token
//			 */
//			if(!AuthUtil.isPassTokenInJsp(request.getRequestURL().toString())
//					&& !RequestToken.isValid(request)) {
//				if (logger.isDebugEnabled())
//					logger.debug("★★★ Reqeust Token Fail  in PreHandler ★★★");
//				throw new Exception(ApplicationContextHolder.getMessage("COM.ERR.002"));
//			}
//			
//			if (logger.isDebugEnabled())
//				logger.debug("★★★ Reqeust Token Success in PreHandler ★★★");
//		}
		return true;
	}
	
//	@Override
//	public void afterCompletion(HttpServletRequest request,
//			HttpServletResponse response, Object handler, Exception ex)
//			throws Exception {
//		logger.info("★★★ AfterCompletion");
//	}
//
//	@Override
//	public void postHandle(HttpServletRequest request,
//			HttpServletResponse response, Object handler,
//			ModelAndView modelAndView) throws Exception {
//		logger.info("★★★ PostHandle");
//	}
}
